#define DEBUG
#include <cstdio>
#include <cassert>
#define MODS 998244353
#define MAXN 54

using namespace std;

void sort(int *x, int *y, int n) {
  int temp;
  for (int i=1; i<n; i++) {
    for (int j=i+1; j<=n; j++) {
      if (x[i]>x[j] || (x[i]==x[j] && y[i]>y[j])) {
	temp=x[i], x[i]=x[j], x[j]=temp;
	temp=y[i], y[i]=y[j], y[j]=temp;
      }
    }
  }
}

int main() {
#ifdef DEBUG
  freopen("4228.in", "r", stdin);
  freopen("4228.out", "w", stdout);
#endif

  int n;
  static int x[MAXN+1], y[MAXN+1];
  scanf("%d", &n);
  for (int i=1; i<=n; i++) {
    scanf("%d %d", x+i, y+i);
  }

  sort(x, y, n);

  static int f[2][MAXN+1][MAXN+1][MAXN+1][MAXN+1];
  f[0][0][0][0][0] = 1;
  for (int i=0; i<n; i++) {
    bool flag;
    for (int j=0; j<=i+1; j++) {
      for (int k=0; k<=i+1; k++) {
	for (int l=0; l<=i+1; l++) {
	  for (int m=0; m<=i+1; m++) {
	    f[(i+1)%2][j][k][l][m] = 0;
	  }
	}
      }
    }

    //up
    flag=true;
    for (int j=i+1+1; j<=n; j++) {
      if (x[i+1]==x[j] && y[i+1]<y[j]) {
	flag = false;
	break;
      }
    }
    if (flag) {
      for (int j=0; j<=i; j++) {
	for (int k=0; k<=i; k++) {
	  for (int l=0; l<=i; l++) {
	    for (int m=0; m<=i; m++) {
	      if (f[i%2][j][k][l][m] && (m==0 || y[i+1]>y[m])) {
		if (k==0 || y[i+1]<y[k]) {
		  f[(i+1)%2][j][i+1][l][m] = (f[(i+1)%2][j][i+1][l][m]+f[i%2][j][k][l][m])%MODS;
		} else {
		  f[(i+1)%2][j][k][l][m] = (f[(i+1)%2][j][k][l][m]+f[i%2][j][k][l][m])%MODS;
		}
	      }
	    }
	  }
	}
      }
    }

    //down
    flag=true;
    for (int j=i; j>0; j--) {
      if (x[i+1]==x[j] && y[i+1]>y[j]) {
	flag = false;
	break;
      }
    }
    if (flag) {
      for (int j=0; j<=i; j++) {
	for (int k=0; k<=i; k++) {
	  for (int l=0; l<=i; l++) {
	    for (int m=0; m<=i; m++) {
	      if (f[i%2][j][k][l][m] && (l==0 || y[i+1]<y[l])) {
		if (j==0 || y[i+1]>y[j]) {
		  f[(i+1)%2][i+1][k][l][m] = (f[(i+1)%2][i+1][k][l][m]+f[i%2][j][k][l][m])%MODS;
		} else {
		  f[(i+1)%2][j][k][l][m] = (f[(i+1)%2][j][k][l][m]+f[i%2][j][k][l][m])%MODS;
		}
	      }
	    }
	  }
	}
      }
    }

    //left
    flag=true;
    for (int j=i; j>0; j--) {
      if (y[i+1]==y[j] && x[i+1]>x[j]) {
	flag = false;
	break;
      }
    }
    if (flag) {
      for (int j=0; j<=i; j++) {
	for (int k=0; k<=i; k++) {
	  for (int l=0; l<=i; l++) {
	    for (int m=0; m<=i; m++) {
	      if (f[i%2][j][k][l][m] && ((j==0 || y[j]<y[i+1]) && (k==0 || y[i+1]<y[k]))) {
		f[(i+1)%2][j][k][l][m] = (f[(i+1)%2][j][k][l][m]+f[i%2][j][k][l][m])%MODS;
	      }
	    }
	  }
	}
      }
    }
    
    //right
    flag=true;
    for (int j=i+1+1; j<=n; j++) {
      if (y[i+1]==y[j] && x[i+1]<x[j]) {
	flag = false;
	break;
      }
    }
    if (flag) {
      for (int j=0; j<=i; j++) {
	for (int k=0; k<=i; k++) {
	  for (int l=0; l<=i; l++) {
	    for (int m=0; m<=i; m++) {
	      if (f[i%2][j][k][l][m]) {
		if (l!=0 && m!=0 && y[l]<y[i+1] && y[i+1]<y[m]) {
		  f[(i+1)%2][j][k][l][m] = (f[(i+1)%2][j][k][l][m]+f[i%2][j][k][l][m])%MODS;
		} else if (l!=0 && m!=0 && y[l]>y[i+1]) {
		    f[(i+1)%2][j][k][i+1][m] = (f[(i+1)%2][j][k][i+1][m]+f[i%2][j][k][l][m])%MODS;
		} else if (l!=0 && m!=0 && y[m]<y[i+1]){
		  f[(i+1)%2][j][k][l][i+1] = (f[(i+1)%2][j][k][l][i+1]+f[i%2][j][k][l][m])%MODS;
		} else {
		  f[(i+1)%2][j][k][i+1][i+1] = (f[(i+1)%2][j][k][i+1][i+1]+f[i%2][j][k][l][m])%MODS;
		}
	      }
	    }
	  }
	}
      }
    }
  }

  long long ans=0;
  for (int i=0; i<=n; i++) {
    for (int j=0; j<=n; j++) {
      for (int k=0; k<=n; k++) {
	for (int l=0; l<=n; l++) {
	  ans = (ans+f[n%2][i][j][k][l])%MODS;
	}
      }
    }
  }
  printf("%lld", ans);

  fcloseall();
  return 0;
}
